const express = require("express");
const path = require("path");

const app = express();
// express 实例上设置 secret 属性
app.set("secret", "这是token加密的字符串");

// 设置允许跨域的中间件
app.use(require("cors")());
app.use(express.json());
app.use("/", express.static(path.join(__dirname, "web")));
app.use("/admin", express.static(path.join(__dirname, "admin")));
app.use("/uploads", express.static(path.join(__dirname, "uploads")));
// 链接数据库
require("./plugins/db")(app);

require("./routes/admin")(app);

require("./routes/web/index")(app);

app.listen(3000, () => {
  console.log("http://localhost:3000");
  // console.log(app.get("secret"));  // get 来获取 set设置的参数
});
